import request from '@/utils/request'

// 不分页查询列表接口
export function list(dataName,requestBody,modelName) {
  if(requestBody == undefined){
    requestBody = {
     
    }
  }
  if(modelName == undefined){
    modelName = 'system'
  }
  return request({
    url: '/'+modelName+'/'+dataName+'/list',
    method: 'post',
    data: requestBody
  })
}


// 分页查询接口
export function listpage(dataName,requestBody,currentPage,pageSize,modelName) {
  if(requestBody == undefined){
    requestBody = {
     
    }
  }
  if(modelName == undefined){
    modelName = 'system'
  }  
  return request({
    url: '/'+modelName+'/'+dataName+'/listpage?currentPage='+currentPage+'&pageSize='+pageSize,
    method: 'post',
    data: requestBody
  })
}

// 查询树形列表接口
export function listTree(dataName,requestBody,modelName) {
  if(requestBody == undefined){
    requestBody = {
      data:{}
    }
  }
  return request({
    url: '/system/'+dataName+'/tree',
    method: 'post',
    data: requestBody
  })
}

// 加载接口
export function load(dataName,id,modelName) {
  if(modelName == undefined){
    modelName = 'system'
  }
  return request({
    url: '/'+modelName+'/'+dataName+'/load/'+id,
    method: 'get'
  })
}

// 保存接口
export function create(dataName,requestBody,modelName) {
  if(modelName == undefined){
    modelName = 'system'
  }
  return request({
    url: '/'+modelName+'/'+dataName+'/add',
    method: 'post',
    data: requestBody
  })
}

// 批量保存接口
export function creates(dataName,requestBody,modelName) {
  
  return request({
    url: '/system/'+dataName+'/creates',
    method: 'post',
    data: requestBody
  })
}

// 修改接口
export function update(dataName,requestBody,modelName) {
  if(modelName == undefined){
    modelName = 'system'
  }
  return request({
    url: '/'+modelName+'/'+dataName+'/update',
    method: 'put',
    data: requestBody
  })
}

// 删除接口
export function remove(dataName,id,modelName) {
  if(modelName == undefined){
    modelName = 'system'
  }
  return request({
    url: '/'+modelName+'/'+dataName+'/delete/'+id,
    method: 'delete'
  })
}

// 批量删除接口
export function removes(dataName,requestBody,modelName) {
  
  return request({
    url: '/system/'+dataName+'/removes',
    method: 'post',
    data: requestBody
  })
}

// 导出接口
export function download(dataName,requestBody,modelName) {
  
  return request({
    url: '/system/'+dataName+'/download',
    method: 'post',
    data: requestBody
  })
}
